#!/bin/sh -e

for patch in *.patch; do
    patch -p1 < "$patch"
done

./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --libexecdir=/usr/bin \
    --localstatedir=/var \
    --disable-systemd-service \
    --enable-pie \
    --enable-dbus-policy \
    --enable-wired \
    PKG_CONFIG="pkgconf --static"

# Don't use systemd as the default name resolver.
clsed 's|method_name = "systemd"|method_name = "resolvconf"|' src/resolve.c

# Update the manual page to reflect upon the change.
clsed '/If not specified/s/systemd/resolvconf/' src/iwd.config.5


make LDFLAGS=-all-static
make DESTDIR="$1" install

clsv -d "$1" iwd.run ead.run
